import request from "@/utils/request";
import dayjs from "dayjs";
import { download, downloadOfGet } from "@/utils/request";

// 查询版本号
export function getVersionListById(params) {
  return request({
    url: "/equipFaultMode/equipFaultMode/findDeviceModelVersion",
    method: "get",
    params,
  });
}
// 查询数据类型下拉选
export function getDataTypeList(params) {
  return request({
    url: "/point/getDataTypeList",
    method: "get",
    params,
  });
}
// 查询列表
export function getListByIdAndVersion(params) {
  return request({
    url: "/faultModeFema/faultModeFema/list",
    method: "get",
    params,
  });
}

// 下载模板
export function importTemplate(data) {
  return download(
    "/faultModeFema/faultModeFema/importTemplate",
    data,
    "fmea配置导入模板.xlsx"
  );
}
// 下载模板get
export function importTemplateOfGet(params) {
  return downloadOfGet(
    "/faultModeFema/faultModeFema/importTemplate",
    "Fmea配置导入模板.xlsx",
    { params }
  );
}

// 导入
export function importData(data) {
  return request({
    url: "/faultModeFema/faultModeFema/importData",
    method: "post",
    data,
  });
}
// 导出
export function exportData(params) {
  return downloadOfGet(
    "/faultModeFema/faultModeFema/export",
    `fmea配置导出${dayjs().format("YYYY-MM-DD HH_mm_ss")}.xlsx`,
    { params }
  );
}

// 编辑保存
export function save(data) {
  return request({
    url: "/faultModeFema/faultModeFema",
    method: "put",
    data,
  });
}

// 导入后保存
export function addBatch(data) {
  return request({
    url: "/faultModeFema/faultModeFema/addBatch",
    method: "post",
    data,
  });
}
// 加载的数据修改后保存
export function editBatch(data) {
  return request({
    url: "/faultModeFema/faultModeFema/editBatch",
    method: "post",
    data,
  });
}

// 删除单行
export function deleteBatch(params) {
  return request({
    url: "/faultModeFema/faultModeFema/" + params.ids,
    method: "delete",
  });
}
// 编辑单行
export function editOneBatch(data) {
  return request({
    url: "/faultModeFema/faultModeFema",
    method: "put",
    data,
  });
}
